package com.als.healthymananger.controller;


import com.als.healthymananger.utils.RespBean;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/util")
public class UtilController {

    /**
     * 未登录
     * @return
     */
    @RequestMapping("/unauthorized")
    @ResponseBody
    public RespBean unauthorized() {
        return new RespBean(401, "用户未登录", null);
    }

    /**
     * 权限不足
     * @param message
     * @return
     */
    @RequestMapping("/forbidden")
    @ResponseBody
    public RespBean forbidden(@RequestParam(value = "message", required = false)String message) {
        if(message == null || message.equals("")) {
            return new RespBean(403, "该用户没有此操作权限", null);
        }
        return new RespBean(403, message, null);
    }

}
